package com.cetccloud.ap.proxy.channel.cossDomain.s30.handler.recv;

import com.alibaba.fastjson.JSON;
import com.cetccloud.ap.proxy.channel.cossDomain.s30.channel.recv.S30RecvChannel;
import com.thunisoft.exchange.gateway.protocol.channel.GatewayChannelMessageType;
import com.thunisoft.exchange.gateway.protocol.channel.GatewayMetadataMessage;
import com.thunisoft.exchange.gateway.protocol.entity.GatewayExchangeNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

/**
 * @ClassName MetaHandler
 * @Description 名录下发
 * @Author superz
 * @Date 2021/4/22 20:47
 * @Version 1.0
 **/
@Slf4j
@Component
public class MetaHandler implements RecvChannelHandler<GatewayMetadataMessage> {

    @Autowired
    private S30RecvChannel s30RecvChannel;

    @Override
    public GatewayChannelMessageType type() {
        return GatewayChannelMessageType.meta;
    }

    @Override
    public void handle(GatewayMetadataMessage channelMessage) {
        log.info("被动接收从域推送的名录数据... 数据: {}", JSON.toJSONString(channelMessage));
        ArrayList<GatewayExchangeNode> exchangeNodes = channelMessage.getData().getMeta();
        s30RecvChannel.setExchangeNodes(exchangeNodes);
    }
}
